package client;

import java.awt.Image;
import java.io.File;
import java.io.IOException;
import java.io.Serializable;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;

public class Item implements Serializable{

	
	/**
	 * @param iconName
	 */

	private static final long serialVersionUID = 1L;
	/**
	 * 
	 */
	
	private int id;
	private String name;
	private String type;
	private String description;
	private int price;
	private int quntity;
	private String saleDet;
	private String iconName;
	private Boolean catalogFlag;
	private Boolean saleFlag;
	private ImageIcon icon = null;
	private int sale;

	public Item() {
	}
	/**
	 * @param id
	 * @param name
	 * @param type
	 */
	public Item(int id, String name, String type,Boolean catalogFlage) {
		this.id = id;
		this.name = name;
		this.type = type;
		this.catalogFlag = catalogFlage;
	}
	
	
	/**
	 * @param id
	 * @param name
	 * @param type
	 * @param description
	 * @param price
	 * @param quntity
	 * @param sale
	 * @param iconName
	 * @param catalogFlag
	 * @param saleFlag
	 * @param sale 
	 */
	public Item(int id, String name, String type, String description,
			int price, int quntity, String saleDetail, String iconName,
			Boolean catalogFlag, Boolean saleFlag, int sale) {
		super();
		this.id = id;
		this.name = name;
		this.type = type;
		this.description = description;
		this.price = price;
		this.quntity = quntity;
		this.saleDet = saleDetail;
		this.iconName = iconName;
		this.catalogFlag = catalogFlag;
		this.saleFlag = saleFlag;
		this.sale = sale;
		//ImageIcon icon2 = null;
		try {
			icon = new ImageIcon(ImageIO.read(new File(iconName)).getScaledInstance(158, 200, Image.SCALE_DEFAULT));
			//Image img1 = icon2.getImage().getScaledInstance(200, 158, Image.SCALE_SMOOTH);
			//this.icon = new ImageIcon(img1);
		} catch (IOException e) {
			e.printStackTrace();
		}

	}
	
	/**
	 * @param saleFlag
	 * @param sale
	 */
	public Item(Boolean saleFlag, int sale) {
		this.saleFlag = saleFlag;
		this.sale = sale;
	}
	/**
	 * @param iconName
	 */
	public Item(String iconName) {
		this.iconName = iconName;
		try {
			icon = new ImageIcon(ImageIO.read(new File(iconName)).getScaledInstance(139, 113, Image.SCALE_DEFAULT));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public void setId(int id) {
		this.id = id;
	}

	public int getId() {
		return id;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getType() {
		return type;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public String getDescription() {
		return description;
	}
	public void setIcon(ImageIcon icon) {
		this.icon = icon;
	}
	public ImageIcon getIcon() {
		return icon;
	}
	public void setPrice(int price) {
		this.price = price;
	}
	public int getPrice() {
		return price;
	}
	public void setCatalogFlag(Boolean catalogFlag) {
		this.catalogFlag = catalogFlag;
	}
	public Boolean getCatalogFlag() {
		return catalogFlag;
	}
	public String getIconName() {
		return iconName;
	}
	public void setIconName(String iconName) {
		this.iconName = iconName;
	}
	public int getQuntity() {
		return quntity;
	}
	public void setQuntity(int quntity) {
		this.quntity = quntity;
	}
	public int getSale() {
		return sale;
	}
	public void setSale(int sale) {
		this.sale = sale;
	}
	public Boolean getSaleFlag() {
		return saleFlag;
	}
	public void setSaleFlag(Boolean saleFlag) {
		this.saleFlag = saleFlag;
	}
	public String getSaleDet() {
		return saleDet;
	}
	public void setSaleDet(String saleDet) {
		this.saleDet = saleDet;
	}
}
